package com.neuedu.autosale.sys.service.impl;

import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neuedu.autosale.entity.Pager;
import com.neuedu.autosale.entity.Result;
import com.neuedu.autosale.mapper.CarMapper;
import com.neuedu.autosale.sys.entity.Car;
import com.neuedu.autosale.sys.service.CarService;

@Service
@Transactional
public class CarServiceImpl implements CarService{
	
	@Autowired
	private CarMapper carmapper;
	
	@Override
	public List<Car> findListByPager(Pager<Car> pager) {
		
		return carmapper.findListBypager(pager);
	}

	@Override
	public Integer findTotalByPager(Pager<Car> pager) {
		
		return carmapper.findTotalByPager(pager);
	}

	@Override
	public Result add(Car object) {
		Result result = new Result(false, "新增失败！");
		boolean ret = carmapper.add(object);
		if (ret) {
			result = new Result(true, "新增成功！");
		}
		return result;
	}

	@Override
	public Result edit(Car object) {
		Result result = new Result(false, "修改失败！");
		boolean ret = carmapper.edit(object);
		if (ret) {
			result = new Result(true, "修改成功！");
		}
		return result;
	}

	@Override
	public Result deleteByIds(List<Car> ids) {
		Result result = new Result(false, "删除失败！");
		boolean ret = carmapper.deleteByIds(ids);
		if (ret) {
			result = new Result(true, "删除成功！");
		}
		return result;
	}

	@Override
	public List<Car> findAll() {
		
		return carmapper.findAll();
	}

}
